import {defineStore} from "pinia";

export const useTokenStore = defineStore("token", {
    //存储数据的地方
    state(){
        return{
            token: null
        }
    },
    //put functions in actions
    actions:{
        setToken(newToken){//add token
            console.log("setToken called");
            this.token = newToken;
        },
        removeToken(){
            console.log("removeToken");
            this.token = null;
        }
    },
    persist:{
        enabled:true //Enable caching, which will be stored in local storage by default.
    }
})